package com.baoyouqun.controller.weixin;

import cn.dev33.satoken.stp.StpUtil;
import com.alibaba.cola.dto.SingleResponse;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baoyouqun.base.PageResponse;
import com.baoyouqun.domain.CreateCmd.CityPartnerApplicationCreateCmd;
import com.baoyouqun.domain.Query.CityPartnerApplicationQuery;
import com.baoyouqun.domain.VO.CityPartnerApplicationVO;
import com.baoyouqun.service.CityPartnerApplicationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("wx/cityPartnerApplication")
@Api(tags = "城市合伙人申请表管理接口")
public class WxCityPartnerApplicationController {

    @Resource
    private CityPartnerApplicationService cityPartnerApplicationService;

    @PostMapping("create")
    @ApiOperation("新增城市合伙人申请表")
    public SingleResponse<CityPartnerApplicationVO> create(@Valid @RequestBody CityPartnerApplicationCreateCmd cmd) {
        String userId = StpUtil.getLoginIdAsString();
        cmd.setUserId(userId);
        return cityPartnerApplicationService.create(cmd);
    }


    @GetMapping("getById")
    @ApiOperation("根据ID查询城市合伙人申请表")
    public SingleResponse<CityPartnerApplicationVO> selectById(String id) {
        return SingleResponse.of(cityPartnerApplicationService.selectById(id));
    }

    @GetMapping("page")
    @ApiOperation("分页查询城市合伙人申请表")
    public PageResponse<CityPartnerApplicationVO> page(CityPartnerApplicationQuery query) {
        String userId = StpUtil.getLoginIdAsString();
        query.setUserId(userId);
        IPage<CityPartnerApplicationVO> page = cityPartnerApplicationService.pageVo(query);
        return PageResponse.of(page.getRecords(), page.getTotal(), page.getCurrent(), page.getSize());
    }
}